package com.ququ.syb.entrance.controller;

import com.ququ.syb.entrance.po.RequestData;
import com.ququ.syb.entrance.service.BankCardService;
import com.ququ.syb.entrance.vo.SybResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 银行卡绑卡模块
 *
 * @author Macro
 * @date 2019-08-21
 *
 */
@RestController
@RequestMapping("/syb/controller")
public class BankCardController {
    @Autowired
    private BankCardService bankCardService;



    /**
     * /p1308 绑定/更换提现卡
     *
     * @param header.terminalno 终端号，随便填|必填
     * @param header.requesttype 请求类型，默认为1|必填
     * @param header.operationid 请求id|必填
     * @param header.appcode 应用代码|必填
     * @param header.terminaltype 默认填1|必填
     * @param header.timestamp 时间戳|必填
     * @param encryptiontype 加密方式 这里填1-AES|必填
     * @param accountid 生意宝账户|必填
     * @param data 业务数据请求部分，JSON格式，AES加密|必填
     * @param data.cardholdermobile 注册手机号|必填
     * @param data.bankaccountname 用户真实姓名|必填
     * @param data.bankaccountno 银行卡号|必填
     * @param data.bankprovince 银行所属省份|必填
     * @param data.cardholderidcard 身份证号|必填
     * @param data.bankcity 银行所属城市|必填
     * @param data.branchno 开户行联行号|必填
     * @param sign 签名
     * @return 当前绑定的提现卡详情
     * @respbody {"status":1,"msg":"成功","data":{"accountid":"100000000064","result":"zc6PZ6KGj/9GXfKwbKFk8CUgzPqAsWOWEcd7OvNQbVP/TTFGqEcle+zKhaHTvzAXK7Q3ZOUOaav48owKvq33OgU5NfPWf1h6J0MEwhfv/Pn/fIbPWLxgh0sVo6pugsVS6eTIdJ0l8C3TzUby3cmm0DIa7ZnjU9iUOxqWEKWzFMkwCMen2JsJHlCe7e36Wg6sGju3rhdpyGLNiCDaq0cP7Nai2qOHwgdNNnMdApT67Ahw2ebVzSApTZDdwJAiEMEvBGKESqdtj+X4vNpSHTQwlahXU27y+DS93BfCFC9i3MacGZYjNAKcRQlzV0A1rbavFAyanPwG5o4UM4/JlM3PR9TU39kc2rEAvCWcDwE1upKJFj1EUGgO5gkrP8JkIheI9KA6k7EirxJFP8YSbLDs+6Wi9peOBsC4QZ5qVWpZeFAosEVypDPbN4Qmydk448RYDm/L8ue89YBN2Fa8BijsQLvyI2wnNZFXc/hEz3n2WWAEtkwoanNxZCsEpjcz6pS+4+YnoqIhJDMg+CCS7IV0xAVf4j0wJ94nizwPx10Mto0+UYBakYwL9wuTBzfPI6t8QP8Vh0pSxNZsHp+NOJDYIGnnhzhU4pFs1g2CVQrEGgOqwBn+TOVoWsxSzQVSHs7XOSRdPwFY9zooPZCewJeh9mzscKYWw5wazkc+g3kF6MsdU4EpcrieJbgVWdP4GtfrA2FmiXyNVCtecSVEMpDFbdL1C/U/aKTX8f65/Lc62fDiyfsyuG2n7Vl0kLn4Tc7U0NZ0PcIHzfs8JN6dKlcwSA=="},"page":{"count":1,"index":1,"size":10,"total":1},"sign":"340dbe16e7ebaf3ce73bdbd0f2ea9684"}
     * @resp status 状态值，1-成功 其他值-失败|int
     * @resp msg 错误信息|string
     * @resp data.accountid 生意宝账号id|string
     * @resp data.result 明文样本 {"accountid":"100000000064","address":"福建省福州市台江区XXXXXXXX","bankaccountname":"张三丰","bankaccountno":"6217001820007925823","bankaccounttype":2,"bankcity":"福州","bankcode":"CCB","bankdetailedname":"中国建设银行股份有限公司福州古田支行","bankname":"建设银行","bankprovince":"福建","branchno":"105391002200","cardholderidcard":"35012519711XXXXXXX","cardholdermobile":"1395028XXXX","cardtype":1,"countrycode":"1030111","createtime":1519893185000,"id":132,"isdeleted":0,"lastmodifytime":1564738800000,"status":1}
     * @resp data.result.accountid 生意宝账号id|string
     * @resp data.result.status 账户状态 1-正常 0-冻结|int
     * @resp data.result.bankaccountname 姓名|string
     * @resp data.result.cardholdermobile 手机号|string
     * @resp data.result.bankaccountno 银行卡号|string
     * @resp data.result.cardholderidcard 身份证号|string
     * @resp data.result.createtime 首次绑卡时间|string
     * @resp data.result.lastmodifytime 更新时间|string
     * @resp data.result.cardtype 银行卡类型 1-储蓄卡 2-信用卡|int
     * @resp data.result.bankcity 开户行城市|string
     * @resp data.result.bankprovince 开户行省份|string
     * @resp data.result.bankcode 银行代码|string
     * @resp data.result.bankname 银行中文简称|string
     * @resp data.result.bankdetailedname 开户行全称|string
     * @resp data.result.branchno 开户行联行号|string
     * @resp data.result.isdeleted 是否已经解绑 0-未解绑 1-解绑|int
     * @resp page 分页信息，可忽略|object
     */
    @RequestMapping("/p1308")
    public SybResult bindBankCard(@RequestHeader String appcode,
                                   @RequestHeader(required = false) String timeStamp,
                                   @RequestHeader(required = false) String operationid,
                                   @RequestHeader(required = false) String operationname,
                                   @RequestParam String accountid,
                                   @RequestParam String data,
                                   @RequestParam String sign,
                                   @RequestParam Integer encryptiontype){
        RequestData<String> requestData = new RequestData<>(appcode,accountid,operationid,operationname,data,sign,encryptiontype);
        return bankCardService.bindBankCard(requestData);
    }


    /**
     * /p1303 查询当前绑定的提现卡
     *
     * @param header.terminalno 终端号，随便填|必填
     * @param header.requesttype 请求类型，默认为1|必填
     * @param header.operationid 请求id|必填
     * @param header.appcode 应用代码|必填
     * @param header.terminaltype 默认填1|必填
     * @param header.timestamp 时间戳|必填
     * @param encryptiontype 加密方式 这里填1-AES|必填
     * @param accountid 生意宝账户|必填
     * @param data 业务数据请求部分，JSON格式，传加密的空值|必填
     * @param sign 签名
     * @return 当前绑定的提现卡详情
     * @respbody {"status":1,"msg":"成功","data":{"accountid":"100000000064","result":"zc6PZ6KGj/9GXfKwbKFk8CUgzPqAsWOWEcd7OvNQbVP/TTFGqEcle+zKhaHTvzAXK7Q3ZOUOaav48owKvq33OgU5NfPWf1h6J0MEwhfv/Pn/fIbPWLxgh0sVo6pugsVS6eTIdJ0l8C3TzUby3cmm0DIa7ZnjU9iUOxqWEKWzFMkwCMen2JsJHlCe7e36Wg6sGju3rhdpyGLNiCDaq0cP7Nai2qOHwgdNNnMdApT67Ahw2ebVzSApTZDdwJAiEMEvBGKESqdtj+X4vNpSHTQwlahXU27y+DS93BfCFC9i3MacGZYjNAKcRQlzV0A1rbavFAyanPwG5o4UM4/JlM3PR9TU39kc2rEAvCWcDwE1upKJFj1EUGgO5gkrP8JkIheI9KA6k7EirxJFP8YSbLDs+6Wi9peOBsC4QZ5qVWpZeFAosEVypDPbN4Qmydk448RYDm/L8ue89YBN2Fa8BijsQLvyI2wnNZFXc/hEz3n2WWAEtkwoanNxZCsEpjcz6pS+4+YnoqIhJDMg+CCS7IV0xAVf4j0wJ94nizwPx10Mto0+UYBakYwL9wuTBzfPI6t8QP8Vh0pSxNZsHp+NOJDYIGnnhzhU4pFs1g2CVQrEGgOqwBn+TOVoWsxSzQVSHs7XOSRdPwFY9zooPZCewJeh9mzscKYWw5wazkc+g3kF6MsdU4EpcrieJbgVWdP4GtfrA2FmiXyNVCtecSVEMpDFbdL1C/U/aKTX8f65/Lc62fDiyfsyuG2n7Vl0kLn4Tc7U0NZ0PcIHzfs8JN6dKlcwSA=="},"page":{"count":1,"index":1,"size":10,"total":1},"sign":"340dbe16e7ebaf3ce73bdbd0f2ea9684"}
     * @resp status 状态值，1-成功 其他值-失败|int
     * @resp msg 错误信息|string
     * @resp data.accountid 生意宝账号id|string
     * @resp data.result 明文样本 {"accountid":"100000000064","address":"福建省福州市台江区XXXXXXXX","bankaccountname":"张三丰","bankaccountno":"6217001820007925823","bankaccounttype":2,"bankcity":"福州","bankcode":"CCB","bankdetailedname":"中国建设银行股份有限公司福州古田支行","bankname":"建设银行","bankprovince":"福建","branchno":"105391002200","cardholderidcard":"35012519711XXXXXXX","cardholdermobile":"1395028XXXX","cardtype":1,"countrycode":"1030111","createtime":1519893185000,"id":132,"isdeleted":0,"lastmodifytime":1564738800000,"status":1}
     * @resp data.result.accountid 生意宝账号id|string
     * @resp data.result.status 账户状态 1-正常 0-冻结|int
     * @resp data.result.bankaccountname 姓名|string
     * @resp data.result.cardholdermobile 手机号|string
     * @resp data.result.bankaccountno 银行卡号|string
     * @resp data.result.cardholderidcard 身份证号|string
     * @resp data.result.createtime 首次绑卡时间|string
     * @resp data.result.lastmodifytime 更新时间|string
     * @resp data.result.cardtype 银行卡类型 1-储蓄卡 2-信用卡|int
     * @resp data.result.bankcity 开户行城市|string
     * @resp data.result.bankprovince 开户行省份|string
     * @resp data.result.bankcode 银行代码|string
     * @resp data.result.bankname 银行中文简称|string
     * @resp data.result.bankdetailedname 开户行全称|string
     * @resp data.result.branchno 开户行联行号|string
     * @resp data.result.isdeleted 是否已经解绑 0-未解绑 1-解绑|int
     * @resp page 分页信息，可忽略|object
     */
    @RequestMapping("/p1303")
    public SybResult getBankCard(@RequestHeader String appcode,
                                   @RequestHeader(required = false) String timeStamp,
                                   @RequestHeader(required = false) String operationid,
                                   @RequestHeader(required = false) String operationname,
                                   @RequestParam String accountid,
                                   @RequestParam String data,
                                   @RequestParam String sign,
                                   @RequestParam Integer encryptiontype){
        RequestData<String> requestData = new RequestData<>(appcode,accountid,operationid,operationname,data,sign,encryptiontype);
        return bankCardService.getBankCard(requestData);
    }



    /**
     * /p1321 绑定支付卡
     *
     * @param header.terminalno 终端号，随便填|必填
     * @param header.requesttype 请求类型，默认为1|必填
     * @param header.operationid 请求id|必填
     * @param header.appcode 应用代码|必填
     * @param header.terminaltype 默认填1|必填
     * @param header.timestamp 时间戳|必填
     * @param encryptiontype 加密方式 这里填1-AES|必填
     * @param accountid 生意宝账户|必填
     * @param data 业务数据请求部分，JSON格式，AES加密|必填
     * @param data.cardholdermobile 注册手机号|必填
     * @param data.bankaccountname 用户真实姓名|必填
     * @param data.bankaccountno 银行卡号|必填
     * @param data.cardholderidcard 身份证号|必填
     * @param sign 签名
     * @return 当前绑定这张支付卡的详情
     * @respbody {"status":1,"msg":"成功","data":{"accountid":"100000000064","result":"zc6PZ6KGj/9GXfKwbKFk8CUgzPqAsWOWEcd7OvNQbVP/TTFGqEcle+zKhaHTvzAXK7Q3ZOUOaav48owKvq33OgU5NfPWf1h6J0MEwhfv/Pn/fIbPWLxgh0sVo6pugsVS6eTIdJ0l8C3TzUby3cmm0DIa7ZnjU9iUOxqWEKWzFMkwCMen2JsJHlCe7e36Wg6sGju3rhdpyGLNiCDaq0cP7Nai2qOHwgdNNnMdApT67Ahw2ebVzSApTZDdwJAiEMEvBGKESqdtj+X4vNpSHTQwlahXU27y+DS93BfCFC9i3MacGZYjNAKcRQlzV0A1rbavFAyanPwG5o4UM4/JlM3PR9TU39kc2rEAvCWcDwE1upKJFj1EUGgO5gkrP8JkIheI9KA6k7EirxJFP8YSbLDs+6Wi9peOBsC4QZ5qVWpZeFAosEVypDPbN4Qmydk448RYDm/L8ue89YBN2Fa8BijsQLvyI2wnNZFXc/hEz3n2WWAEtkwoanNxZCsEpjcz6pS+4+YnoqIhJDMg+CCS7IV0xAVf4j0wJ94nizwPx10Mto0+UYBakYwL9wuTBzfPI6t8QP8Vh0pSxNZsHp+NOJDYIGnnhzhU4pFs1g2CVQrEGgOqwBn+TOVoWsxSzQVSHs7XOSRdPwFY9zooPZCewJeh9mzscKYWw5wazkc+g3kF6MsdU4EpcrieJbgVWdP4GtfrA2FmiXyNVCtecSVEMpDFbdL1C/U/aKTX8f65/Lc62fDiyfsyuG2n7Vl0kLn4Tc7U0NZ0PcIHzfs8JN6dKlcwSA=="},"page":{"count":1,"index":1,"size":10,"total":1},"sign":"340dbe16e7ebaf3ce73bdbd0f2ea9684"}
     * @resp status 状态值，1-成功 其他值-失败|int
     * @resp msg 错误信息|string
     * @resp data.accountid 生意宝账号id|string
     * @resp data.result 明文样本 {"accountid":"100000000064","address":"福建省福州市台江区XXXXXXXX","bankaccountname":"张三丰","bankaccountno":"6217001820007925823","bankaccounttype":2,"bankcity":"福州","bankcode":"CCB","bankdetailedname":"中国建设银行股份有限公司福州古田支行","bankname":"建设银行","bankprovince":"福建","branchno":"105391002200","cardholderidcard":"35012519711XXXXXXX","cardholdermobile":"1395028XXXX","cardtype":1,"countrycode":"1030111","createtime":1519893185000,"id":132,"isdeleted":0,"lastmodifytime":1564738800000,"status":1}
     * @resp data.result.accountid 生意宝账号id|string
     * @resp data.result.status 账户状态 1-正常 0-冻结|int
     * @resp data.result.bankaccountname 姓名|string
     * @resp data.result.cardholdermobile 手机号|string
     * @resp data.result.bankaccountno 银行卡号|string
     * @resp data.result.cardholderidcard 身份证号|string
     * @resp data.result.createtime 首次绑卡时间|string
     * @resp data.result.lastmodifytime 更新时间|string
     * @resp data.result.cardtype 银行卡类型 1-储蓄卡 2-信用卡|int
     * @resp data.result.bankcode 银行代码|string
     * @resp data.result.bankname 银行中文简称|string
     * @resp page 分页信息，可忽略|object
     */
    @RequestMapping("/p1321")
    public SybResult bindPayBankCard(@RequestHeader String appcode,
                                       @RequestHeader(required = false) String timeStamp,
                                       @RequestHeader(required = false) String operationid,
                                       @RequestHeader(required = false) String operationname,
                                       @RequestParam String accountid,
                                       @RequestParam String data,
                                       @RequestParam String sign,
                                       @RequestParam Integer encryptiontype){
        RequestData<String> requestData = new RequestData<>(appcode,accountid,operationid,operationname,data,sign,encryptiontype);
        return bankCardService.bindPayBankCard(requestData);
    }


}
